package com.whmskj.xjlhbc.dto;

import cn.hutool.core.date.BetweenFormatter;
import cn.hutool.core.date.DateUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@Schema(name = "扫一扫响应参数",description = "扫一扫响应参数")
public class ScanDto {

    @Schema(title = "设备详情")
    private Info topInfo = new Info();

    @Schema(title = "type = 1的实时运行数据")
    private Object rundataInfo = new Object();

    @Schema(title = "产量统计")
    private ClInfo clInfo = new ClInfo();

    @Schema(title = "停车数据")
    private List<StopInfo> stopInfo = new ArrayList<>();

    @Schema(title = "维保记录")
    private WbGzInfo wbInfo = new WbGzInfo();

    @Schema(title = "故障记录")
    private WbGzInfo gzInfo = new WbGzInfo();

    @Schema(title = "运行记录")
    private List<Object> runInfoList = new ArrayList();

    @Schema(title = "锅炉报警记录")
    private WbGzInfo glWarnList = new WbGzInfo();

    @Data
    public static class Info{
        @Schema(description = "设备名称")
        private String deviceName;

        @Schema(description = "设备编码")
        private String deviceCode;

        @Schema(description = "挡车工")
        private String userName = "空";

        @Schema(description = "状态")
        private String state = "运行";

        @Schema(description = "1:织布机,2:整经机,3:浆纱机")
        private int type;
    }

    @Data
    public static class ClInfo{
        @Schema(description = "本周")
        private String bz;

        @Schema(description = "本月")
        private String by;

        @Schema(description = "本年")
        private String bn;

        private List<Object> clList = new ArrayList<>();

    }

    @Data
    public static class StopInfo{
        @Schema(description = "类型")
        private String type;

        @Schema(description = "次数")
        private int total;

        @Schema(description = "时长")
        private long stoptime;

        public String getStoptime() {
            return DateUtil.formatBetween(stoptime*1000, BetweenFormatter.Level.SECOND);
        }
    }

    @Data
    public static class WbGzInfo{
        @Schema(description = "本月总次数")
        private long total;

        private List<Object> list = new ArrayList<>();
    }

    @Data
    public static class JzkInfo{
        @Schema(description = "存轴数")
        private long cz;

        @Schema(description = "轴长")
        private long zc;

        @Schema(description = "布号")
        private long bh;

        private List<Object> list = new ArrayList<>();
    }

}
